package com.turbo.cloud.contract.config;

import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Date;


/**
 * 文件路径配置
 * @author zhangluning
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Component
@ConfigurationProperties(prefix="contract-application.file-path", ignoreInvalidFields = true)
public class FilePathConfig {

    private final static String DATE_FORMAT_YMD = "yyyyMMdd";
    /**
     * 文件根目录
     * */
    private String rootPath;
    /**
     * 上传文件根目录
     * */
    private String uploadPath;
    /**
     * 下载文件根目录
     * */
    private String downloadPath;

    /**
     * 获取上传跟目录
     * */
    public String getUploadPathOfYMD() {
        String todayStr = DateUtil.format(new Date(), DATE_FORMAT_YMD);
        return uploadPath + File.separator + todayStr + File.separator;
    }

    /**
     * 获取下载跟目录
     * */
    public String getDownloadPathOfYMD() {
        String todayStr = DateUtil.format(new Date(), DATE_FORMAT_YMD);
        return uploadPath + File.separator + todayStr + File.separator;
    }
}
